ARG UBUNTU_VER=18.04
ARG CONDA_VER=latest
ARG OS_TYPE=x86_64
ARG PY_VER=3.8.11
ARG TF_VER=2.5.0


FROM ubuntu:${UBUNTU_VER}

# 镜像作者GSS
MAINTAINER GSS

# 修改apt源
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update
RUN apt-get upgrade

# 安装ping，wget，ifconfig，vim, redis客户端，mysql客户端等工具
RUN apt-get install -y \
    iputils-ping \
    wget \
    lsof \
    openssh-server \
    net-tools \
    vim \
    tree \
    curl \
    iproute2 \
    redis-tools \
    mysql-client


# miniconda
ARG CONDA_VER
ARG OS_TYPE
# RUN curl -LO "http://repo.continuum.io/miniconda/Miniconda3-${CONDA_VER}-Linux-${OS_TYPE}.sh"
COPY ./Miniconda3-latest-Linux-x86_64.sh  /
RUN bash Miniconda3-${CONDA_VER}-Linux-${OS_TYPE}.sh -p /opt/miniconda -b
RUN rm Miniconda3-${CONDA_VER}-Linux-${OS_TYPE}.sh
ENV PATH=/opt/miniconda/bin:${PATH}
RUN conda update -y conda


# conda 换源
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
RUN conda config --set show_channel_urls yes

ARG PY_VER
ARG TF_VER
RUN conda install -c anaconda -y python=${PY_VER}
# pip 换源
RUN pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
RUN conda env list

# ssh
RUN mkdir -p mkdir/root/.ssh \
    # 修改root密码 便于远程登录
    && echo root:123456 | chpasswd \
    && sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
    && sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config

# 添加环境变量（注意ENV的作用域只在容器, 如用ssh连接服务则ENV不顶用，还需要操作~/.bashrc文件）
RUN echo export PATH=/opt/miniconda/bin:$\PATH >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"

COPY ./start.sh  /

# 如果构建镜像时，想做一些额外的操作，建议在写在这个位置，以便构建镜像时，仍然可以使用之前的缓存
RUN apt-get install -y lsb-release

ENTRYPOINT /bin/bash /start.sh






